<template>
  <a-card :bordered="false">
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">

        <a-row :gutter="24" style="padding-top: 30px">
          <a-col :md="6" :sm="8">
            <a-form-item label="工单号" :label-col="{ span: 5 }" :wrapper-col="{ span: 16 }">
              <a-input placeholder="工单号" v-model="queryParam.supplierWorkNo"></a-input>
            </a-form-item>
          </a-col>
          <a-col :md="18" :sm="16">
            <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
              <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
              <a-button type="primary" @click="showOrClose" icon="search" style='margin-left: 10px;'>高级查询</a-button>
               <a-button type="primary" icon="download" @click="handleExportXls('eip_work_order')"
                         style='margin-left: 10px;'>导出</a-button>
            </span>
          </a-col>
        </a-row>
      </a-form>

    </div>
    <a-row v-if="show">
      <a-col :md="6" :sm="8">
        <a-form-item label="工序" :label-col="{ span: 5 }" :wrapper-col="{ span: 16 }">
          <a-input placeholder="工序" v-model="queryParam.pdCode"></a-input>
        </a-form-item>
      </a-col>

      <a-col :md="6" :sm="8">
        <a-form-item label="产品厂内编号" :label-col="{ span: 5 }" :wrapper-col="{ span: 16 }">
          <a-input placeholder="产品厂内编号" v-model="queryParam.productModel"></a-input>
        </a-form-item>
      </a-col>
      <a-col :md="6" :sm="8">
        <a-form-item label="生产设备名称" :label-col="{ span: 6}" :wrapper-col="{ span: 15 }">
          <a-input placeholder="生产设备名称" v-model="queryParam.equipmentName"></a-input>
        </a-form-item>
      </a-col>
      <a-col :md="6" :sm="8">
        <a-form-item label="供应商工单编号" :label-col="{ span: 7 }" :wrapper-col="{ span: 14 }">
          <a-input placeholder="供应商工单编号" v-model="queryParam.supplierWorkNo"></a-input>
        </a-form-item>
      </a-col>
      <a-col :md="6" :sm="8">
        <a-form-item label="开始采集时间" :label-col="{ span: 7 }" :wrapper-col="{ span: 14 }">
          <a-date-picker v-model="queryParam.startCheckTime"/>
        </a-form-item>
      </a-col>
      <a-col :md="6" :sm="8">
        <a-form-item label="结束采集时间" :label-col="{ span: 7 }" :wrapper-col="{ span: 14 }">
          <a-date-picker v-model="queryParam.endCheckTime"/>
        </a-form-item>
      </a-col>

      <a-col :md="6" :sm="8">
        <a-form-item label="组织架构" :label-col="{ span: 5 }" :wrapper-col="{ span: 16 }">
          <a-select
            v-model="value"
            mode="multiple"
            style="width: 100%"
            placeholder="select one country"
            option-label-prop="label"
          >
            <a-select-option value="平高电器" label="平高电器">
              平高电器
            </a-select-option>
            <a-select-option value="组合电器" label="组合电器">
                 <span role="img" aria-label="组合电器">
                   平高
                 </span>
              组合电器
            </a-select-option>
            <a-select-option value="断路器" label="断路器">
                 <span role="img" aria-label="断路器">
                   平高
                 </span>
              断路器
            </a-select-option>
            <a-select-option value="平芝" label="平芝">
              平芝
            </a-select-option>
          </a-select>
        </a-form-item>
      </a-col>
    </a-row>
    <!-- table区域-begin -->
    <div>
      <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">
        <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择 <a style="font-weight: 600">{{
        selectedRowKeys.length }}</a>项
        <a style="margin-left: 24px" @click="onClearSelected">清空</a>
      </div>

      <a-table
        ref="table"
        size="middle"
        bordered
        rowKey="puid"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
        @change="handleTableChange">

        <template slot="imgSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无此图片</span>
          <img v-else :src="getImgView(text)" height="25px" alt="图片不存在"
               style="max-width:80px;font-size: 12px;font-style: italic;"/>
        </template>
        <template slot="fileSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无此文件</span>
          <a-button
            v-else
            :ghost="true"
            type="primary"
            icon="download"
            size="small"
            @click="uploadFile(text)">
            下载
          </a-button>
        </template>

        <span slot="action" slot-scope="text, record">
          <a @click="handleEdit(record)">编辑</a>

          <a-divider type="vertical"/>
          <a-dropdown>
            <a class="ant-dropdown-link">更多 <a-icon type="down"/></a>
            <a-menu slot="overlay">
              <a-menu-item>
                <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
                  <a>删除</a>
                </a-popconfirm>
              </a-menu-item>
            </a-menu>
          </a-dropdown>
        </span>
      </a-table>
    </div>
    <zpgEipZhdqLdcjsy-modal ref="modalForm" @ok="modalFormOk"></zpgEipZhdqLdcjsy-modal>
  </a-card>
</template>

<script>

  import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  import ZpgEipZhdqLdcjsyModal from './modules/ZpgEipZhdqLdcjsyModal'

  export default {
    name: 'ZpgEipZhdqLdcjsyList',
    mixins: [JeecgListMixin],
    components: {
      ZpgEipZhdqLdcjsyModal
    },
    data() {
      return {
        description: 'zpg_eip_zhdq_ldcjsy管理页面',
        show: false,
        orgName1: '',
        orgName2: '',
        org1: '',
        org2: '',
        // 表头
        columns: [
          {
            title: '供应商工单编号',
            align: 'center',
            dataIndex: 'supplierWorkNo'
          },
          {
            title: '国网侧供应商编码',
            align: 'center',
            dataIndex: 'supplierCode'
          },
          {
            title: '物资品类类型',
            align: 'center',
            dataIndex: 'categoryType'
          },
          {
            title: '供应商产品厂内编码',
            align: 'center',
            dataIndex: 'productModel'
          },
          {
            title: '生产设备名称',
            align: 'center',
            dataIndex: 'equipmentName'
          },
          {
            title: '波头时间',
            align: 'center',
            dataIndex: 'waveHeadTime'
          },
          {
            title: '波尾时间',
            align: 'center',
            dataIndex: 'waveEndTime'
          },
          {
            title: '峰值',
            align: 'center',
            dataIndex: 'paekValue'
          },
          {
            title: '波形数据',
            align: 'center',
            dataIndex: 'waveform'
          },
          {
            title: '采集时间',
            align: 'center',
            dataIndex: 'checkTime',
            customRender: function(text) {
              return !text ? '' : (text.length > 10 ? text.substr(0, 10) : text)
            }
          },
          {
            title: '工序',
            align: 'center',
            dataIndex: 'pdCode'
          },
          {
            title: '操作',
            dataIndex: 'action',
            align: 'center',
            scopedSlots: { customRender: 'action' }
          }
        ],
        url: {
          list: '/zpgEipZhdqLdcjsy/selectForList',
          delete: '/zpgEipZhdqLdcjsy/delete',
          // deleteBatch: "/zpgEipZhdqLdcjsy/deleteBatch",
          exportXlsUrl: '/zpgEipZhdqLdcjsy/exportXls'
          // importExcelUrl: "pg/zpgEipZhdqLdcjsy/importExcel",
        },
        dictOptions: {}
      }
    },
    computed: {
      importExcelUrl: function() {
        return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`
      }
    },
    methods: {
      initDictConfig() {
      },
      showOrClose() {
        this.show = !this.show
      }

    }
  }
</script>
<style scoped>
  @import '~@assets/less/common.less'
</style>